#ifndef PPMD_UTILS_HPP
#define PPMD_UTILS_HPP
/*
ppmd_utils.hpp
2014/10/30
psycommando@gmail.com
Description: 
    A header containing interfaces for the static/dynamic library.

    #TODO: A lot of things to figure out here.
           - How to access data like images and etc? How to make it cross the DLL/SO's boundaries?
           - How to handle specific data like images and sprites and etc ?
             Should we let the client figure out what to use, or create an
             abstraction layer ?
           - What languages are we targeting with this? C, C++, C#, Python, VB, Lua ?
*/

//====================================================
// Defines, Macros and Stuff
//====================================================
#ifdef PPMD_DYNAMIC_LIB //If we're building a dynamically linked library
    #ifdef _WIN32
        #define PPMDEXPORT __declspec(dllexport)
    #elif defined(__linux__)
        #define PPMDEXPORT
    #endif
#elif defined(PPMD_STATIC_LIB) //If we're building a static linked library
    #define PPMDEXPORT
#endif

//====================================================
// Actual interface
//====================================================

namespace pmd2
{
//====================================================
// Enums
//====================================================
    enum struct PPMDEXPORT efiletype : unsigned int
    {
        INVALIDFILE,
        KAOMADO,
        SPRITE,
        AT4PX,
        PKDPX,
    };

//====================================================
// Structs
//====================================================

    /*
        This is used by the library client to refer to a particlar file 
        that was loaded by the library.
    */
    struct PPMDEXPORT filehndl
    {
        unsigned int       _fileid;
        unsigned long long _filelen;
        char               _filepath[256];
    };
    
    /*
        This is returned when opening a file using the interface below.
    */
    struct PPMDEXPORT resultfopen
    {
        bool      _bfilewasopened;      //Tells whether we were able to even open the file
        efiletype _typeoffileopened;    //Contains info on the type of file we opened after analysis
        filehndl  _myhandle;            //A file handle refering to the file that was opened
    };

//====================================================
// Classes
//====================================================


    /*
        Interface exporting most functionalities of the library.
    */
    class PPMDEXPORT CPPMD_Utils
    {
    public:

        //-----------------------------------------------------
        // Factory Methods
        //-----------------------------------------------------

        /*
            Instantiate the object. The client is NOT responsible
            for clearing resources. The library will handle it.
            So don't ever delete the pointer you get here!
        */
        static CPPMD_Utils * getInst();

        //-----------------------------------------------------
        // Exposed Methods
        //-----------------------------------------------------

        virtual resultfopen OpenFile ( char * const filepath )       = 0;
        virtual bool        CloseFile( const filehndl & filetoclose )= 0;
    };

};


#endif